|
STEP 13: Browser Compatibility: EMBED meets OBJECT
|
Up until now, this tutorial has dealt only with the embedding of a Beatnik Plug-in in an HTML page. Of course, the goal of any Web content developer is to open up their content to as wide an audience as possible. Well, the good news is that the Beatnik Player is available for both Netscape Navigator as well as Microsoft Internet Explorer.
Microsoft's technology for embedding rich media into HTML pages is called ActiveX. And Internet Explorer's equivalent of a Netscape plug-in is called an ActiveX control. While IE may do some tricky things when it encounters an EMBED tag, and it may even be possible to get IE to use the Beatnik ActiveX control in some cases when only an EMBED tag for an RMF file is specified, the only truly safe way to ensure that IE does the right thing is to use its preferred language - the OBJECT tag.
So, if Internet Explorer wants to see an OBJECT tag and Navigator wants to see an EMBED tag, the first question that comes to mind is: "Can one put both tags on the page so that both browsers are happy?" Well, the answer is a resounding yes - provided that you place these tags in the HTML page in a specific way, as shown in our example below. For our example we have taken the same EMBED tag we used in the first step of this tutorial. The example first shows just the EMBED tag, and then the magical EMBED / OBJECT combination that works in both browsers. The extra HTML code that has been added in the second stage is highlighted in red.
| Netscape Navigator ONLY |
<EMBED SRC="trance.rmf" TYPE="audio/rmf" WIDTH=144 HEIGHT=60 DISPLAY=SONG AUTOSTART=FALSE LOOP=FALSE PLUGINSPAGE="http://www.beatnik.com/to/?player" > |
| Netscape Navigator AND Microsoft Internet Explorer |
<OBJECT CLASSID="CLSID:B384F118-18EE-11D1-95C8-00A024330339" CODEBASE="http://download.beatnik.com/beatnik-player/beatnik-player.cab" WIDTH=144 HEIGHT=60 > <PARAM NAME="SRC" VALUE="trance.rmf"> <PARAM NAME="WIDTH" VALUE="144"> <PARAM NAME="HEIGHT" VALUE="60"> <PARAM NAME="DISPLAY" VALUE="SONG"> <PARAM NAME="AUTOSTART" VALUE="FALSE"> <PARAM NAME="LOOP" VALUE="FALSE"> <EMBED SRC="trance.rmf" TYPE="audio/rmf" WIDTH=144 HEIGHT=60 DISPLAY=SONG AUTOSTART=FALSE LOOP=FALSE PLUGINSPAGE="http://www.beatnik.com/to/?player" > <\OBJECT> |
Now, how does this EMBED / OBJECT tag combination work in both browsers? Well, Netscape Navigator does not observe the OBJECT tag, but sees the EMBED tag buried between the opening and closing OBJECT tags and embeds a plug-in instance accordingly. Conversely, browsers that support the OBJECT tag - such as Internet Explorer - know to ignore any HTML tags between the opening and closing OBJECT tags, other than valid PARAM tags that are used to pass customizable values to the ActiveX control.
So, when combining both the EMBED and OBJECT tags, it is imperative that the EMBED tag be wrapped between <OBJECT> and </OBJECT>. Otherwise, you may in some cases end up with two of exactly the same music file playing on top of each other, but out of sync - not too much fun to listen to.
There are some significant differences between the OBJECT tag and the EMBED tag. For one, the OBJECT tag is a container tag, unlike the EMBED tag which does not need a closing tag. Also, the OBJECT tag does not allow customizable ActiveX control properties to be specified using attributes like with the EMBED tag. Rather, an ActiveX control's customizable properties need to be specified between the opening and closing OBJECT tags, using the PARAM tag.
The PARAM tag takes two attributes - NAME and VALUE. So, when you would just specify LOOP=TRUE inside the EMBED tag, with the OBJECT tag syntax you would have to specify
There are also some special attributes that need to be placed inside the opening OBJECT tag in order to embed music in Internet Explorer using the Beatnik Player. These are...
Now, while combining the EMBED and OBJECT tags achieves compatibility between Navigator and Internet Explorer, it does require a little extra effort and will add a tiny amount to the size of your Web pages. This is a small trade-off when compared to the benefit of reaching a wider audience with your Beatnik content.
To make your life as a Beatnik content developer a little easier, Beatnik Inc. has gone to the trouble of designing the free Beatnik EMBEDifier tool - a convenient way of creating your own custom EMBED / OBJECT code. Using the EMBEDifier is a breeze...